var mySwiper;
$(function(){
	var str=localStorage.getItem('goodsID');
		$.ajax({
			type:"get",
			url:"http://datainfo.duapp.com/shopdata/getGoods.php",
			dataType:'jsonp',
			data:{goodsID:str},
			success:function(data){
				var data=data[0];
//					console.log(data);
				$('.swiper-containers .swiper-wrapper').html('');
				var banner = '';
				var arr = eval(data.imgsUrl);
//				console.log(arr)
				for(var i=0;i<arr.length;i++){
					banner+="<div class='swiper-slide slideq'><img src='"+arr[i]
					+"' /></div>"
				}
				$('.swiper-containers .swiper-wrapper').append(banner);
				$('.p1').html(data.goodsName);
				$('.s1').html('￥'+data.price);
				$('.p2').html('购买人数:'+data.buynumber);
				mySwiper = new Swiper('.swiper-containers',{
					pagination : '.swiper-pagination',
				})
				$('.header6 span').click(function(){
					window.location.href="newgoods.html"
				})
			}
		});
	$('.shop a').click(function(){
		$.ajax({
			type:'get',
			url:'http://datainfo.duapp.com/shopdata/updatecar.php',
			data:{userID:sessionStorage.getItem('auto')||localStorage.getItem('auto'),
			goodsID:localStorage.getItem('goodsID')},
			success:function(data){
				if(data==1){
					alert('添加购物车成功');
				}
				else if(data==0){
					alert('添加购物车失败，请登录');
				}
			}
		})
	})
	$('.sera').click(function(){
		window.location.href="detaild-text.html";
	})
})
			


